<?php

/**
 * This is the model class for table "external_exam".
 *
 * The followings are the available columns in table 'external_exam':
 * @property integer $id
 * @property string $lids_od
 * @property string $lids_os
 * @property string $conjunctivae_od
 * @property string $conjunctivae_os
 * @property string $discharge_od
 * @property string $discharge_os
 * @property string $lacrimal_od
 * @property string $lacrimal_os
 * @property string $tbut_od
 * @property string $tbud_os
 * @property string $schimer_od
 * @property string $schimer_os
 * @property integer $rx_id
 * @property integer $personalinfo_id
 *
 * The followings are the available model relations:
 * @property Rx $rx
 * @property PersonalInformation $personalinfo
 */
class ExternalExam extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return ExternalExam the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'external_exam';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('rx_id, personalinfo_id', 'numerical', 'integerOnly'=>true),
			array('lids_od, lids_os, conjunctivae_od, conjunctivae_os, discharge_od, discharge_os, lacrimal_od, lacrimal_os, tbut_od, tbud_os, schimer_od, schimer_os', 'length', 'max'=>5),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, lids_od, lids_os, conjunctivae_od, conjunctivae_os, discharge_od, discharge_os, lacrimal_od, lacrimal_os, tbut_od, tbud_os, schimer_od, schimer_os, rx_id, personalinfo_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'rx' => array(self::BELONGS_TO, 'Rx', 'rx_id'),
			'personalinfo' => array(self::BELONGS_TO, 'PersonalInformation', 'personalinfo_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'lids_od' => 'Lids Od',
			'lids_os' => 'Lids Os',
			'conjunctivae_od' => 'Conjunctivae Od',
			'conjunctivae_os' => 'Conjunctivae Os',
			'discharge_od' => 'Discharge Od',
			'discharge_os' => 'Discharge Os',
			'lacrimal_od' => 'Lacrimal Od',
			'lacrimal_os' => 'Lacrimal Os',
			'tbut_od' => 'Tbut Od',
			'tbud_os' => 'Tbud Os',
			'schimer_od' => 'Schimer Od',
			'schimer_os' => 'Schimer Os',
			'rx_id' => 'Rx',
			'personalinfo_id' => 'Personalinfo',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('lids_od',$this->lids_od,true);
		$criteria->compare('lids_os',$this->lids_os,true);
		$criteria->compare('conjunctivae_od',$this->conjunctivae_od,true);
		$criteria->compare('conjunctivae_os',$this->conjunctivae_os,true);
		$criteria->compare('discharge_od',$this->discharge_od,true);
		$criteria->compare('discharge_os',$this->discharge_os,true);
		$criteria->compare('lacrimal_od',$this->lacrimal_od,true);
		$criteria->compare('lacrimal_os',$this->lacrimal_os,true);
		$criteria->compare('tbut_od',$this->tbut_od,true);
		$criteria->compare('tbud_os',$this->tbud_os,true);
		$criteria->compare('schimer_od',$this->schimer_od,true);
		$criteria->compare('schimer_os',$this->schimer_os,true);
		$criteria->compare('rx_id',$this->rx_id);
		$criteria->compare('personalinfo_id',$this->personalinfo_id);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
	public function getFName()
        {       
        return $this->personal_information['FullName']; 
        }
}